package org.uva.streambuilder;

import java.applet.Applet;
import java.awt.Color;
import java.util.Observable;


public class CountingStreamModule extends StreamModule implements Runnable {

	double count = 0;
	Thread moduleClock = null;
	boolean running = true;
	
	public CountingStreamModule(Applet app, int x, int y) {
		super(app, x, y);
		this.defaultColor = new Color(243, 179, 69);
		this.selectColor = new Color(200, 20, 0, 200);
		
		this.name = "Counter";
		this.bx = 150;
		
		moduleClock = new Thread(this);
		moduleClock.start();
	}
	
	public void destroy()
	{
		moduleClock = null;
	}
	
	public void run()
	{
		while(running) {
		try {
			count+=1;
	
			setValue( count );
			Thread.sleep(200);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}
	}
	
	public void update(Observable o, Object arg){};

}
